home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
The CICA Windows Explosion!
/
The CICA Windows Explosion! - Disc 2.iso
/
programr
/
appsrcs.zip
/
APPUN.ZIP
/
APPBROWS.C
next >
Wrap
C/C++ Source or Header
|
1993-03-22
|
2KB
|
71 lines
#define STRICT
//compile with the strictest error checking
#define STRICT
#include <windows.h>
#include <windowsx.h>
#include <shellapi.h>
#include <ctl3d.h>
#include "apprun.h"
// !!!!! Don't forget to link commdlg.dll !!!!!
/*--------------------------------------------------------------------------*/
BOOL FAR PASCAL OpenHook(HWND hwnd, int wm, int wParam, long lParam)
{
switch (wm) {
case WM_INITDIALOG:
// We must call this to subclass the directory listbox even
// if the app calls Ctl3dAutoSubclass (commdlg bug)
Ctl3dSubclassDlg(hwnd, CTL3D_ALL);
break;
}
return FALSE;
}
/*--------------------------------------------------------------------------*/
BOOL PASCAL BrowseFile(HWND hWndCommDlgParent, char *FileName)
{
OPENFILENAME ofn;
char szDirName[256];
char szFile[256], szFileTitle[256]; /* file and title arrays */
char *szExeFilter[] = {
"Executable Files",
"*.exe;*.com;*.pif",
"All Files",
"*.*",
""
};
/* Initialize the OPENFILENAME members */
GetWindowsDirectory((LPSTR)szDirName, 255);
szFile[0] = '\0';
ofn.lStructSize = sizeof(OPENFILENAME);
ofn.hwndOwner = hWndCommDlgParent;
ofn.lpstrFilter = szExeFilter[0];
ofn.lpstrTitle = (LPSTR) "AppRun - Browse";
ofn.lpstrInitialDir = szDirName;
ofn.lpstrCustomFilter = (LPSTR) NULL;
ofn.nMaxCustFilter = 0L;
ofn.nFilterIndex = 1L;
ofn.lpstrFile= szFile;
ofn.nMaxFile = sizeof(szFile);
ofn.lpstrFileTitle = szFileTitle;
ofn.nMaxFileTitle = sizeof(szFileTitle);
ofn.Flags = OFN_PATHMUSTEXIST | OFN_FILEMUSTEXIST;
ofn.lpfnHook = MakeProcInstance(OpenHook, hInst);
ofn.nFileOffset = 0;
ofn.nFileExtension = 0;
ofn.lpstrDefExt = (LPSTR) NULL;
/* Call the GetOpenFilename function */
if(GetOpenFileName(&ofn))
{
strcpy(FileName, (char *) ofn.lpstrFile);
return TRUE;
}
else
return FALSE;
}